'use strict';

/**
 * @ngdoc function
 * @name payPcApp.controller:AboutCtrl
 * @description
 * # AboutCtrl
 * Controller of the payPcApp
 */
angular.module('payPcApp')
    .controller('HeaderCtrl', function($scope, $state, $location, user_model, AppConfig) {
        // console.log(AppConfig.get_login_identity());
        $scope.name = $state.current.name;

        $scope.is_login = AppConfig.is_login();

        $scope.cancellogin = function() {
            swal({
                title: "注销?",
                text: "您确定要退出账号么!",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定退出",
                cancelButtonText: "点错了!",
                closeOnConfirm: true,
                closeOnCancel: true
            }, function(isConfirm) {
                if (isConfirm) {
                    user_model.cancel().success(function(resp) {
                        console.log(resp);
                        if (resp.statusCode == 0) {
                            AppConfig.logout();
                            $location.path('/login');
                        };
                    })
                }
            });
        }
    });